# -*- coding: latin1 -*-
#+
#
#- 

import os
from osgeo import gdal, gdalconst

path = r'D:\User\joao.victor\Documents\Imazon\Dados_RAISG\Classification\ajustado\2000_geo'

# set workspace.
os.chdir(path)

fileName = '1_57_020328w_dtc'

gdal.AllRegister()
driver = gdal.GetDriverByName('ENVI')
driver.Register()

dataSet = gdal.Open(fileName, gdalconst.GA_ReadOnly)

if dataSet is not None:
    print fileName
    
    # Getting dims info
    ns = dataSet.RasterXSize
    nl = dataSet.RasterYSize
    nb = dataSet.RasterCount
    
    print 'NS = ', ns
    print 'NL = ', nl
    print 'NB = ', nb
    
    # Getting georreference info
    print dataSet.GetGeoTransform()
    
    originX = dataSet.GetGeoTransform()[0]
    originY = dataSet.GetGeoTransform()[3]
    pixelWidth = dataSet.GetGeoTransform()[1]
    pixelHeigth = dataSet.GetGeoTransform()[5]
    
    band = dataSet.GetRasterBand(1)
    
    print type(band)
    
    data = band.ReadAsArray(0, 0, ns, nl)
    print data
    
else:
    print r'Nao pode abrir a imagem'
# End    
    
    
    
    
    
    
